// Package global
// @Author: zhangdi
// @File: callback_mouse
// @Version: 1.0.0
// @Date: 2023/5/30 17:49
package entry

import (
	"ideatools/application/constant"
	"ideatools/application/db/dbservice"
	"ideatools/application/pkgs/mylog"
	"strconv"
)

func CallBackMouseLongClick(code uint16) {
	if notifyFrontMouseLong(code) {
		//发送成功说明正在监听中
		return
	}
	quickOpenByMouseButton := ConfigService.GetBool(constant.ConfigKeyOpenQuickByMouseButton)

	if quickOpenByMouseButton {
		LongClickCode := ConfigService.Get(constant.ConfigKeyOpenMouseButtonCodes)
		if strconv.Itoa(int(code)) == LongClickCode {
			mylog.Debug("长按事件快启动" + strconv.Itoa(int(code)) + LongClickCode)
			ShowOrHideApp()
		}
	}
}

func notifyFrontMouseLong(code uint16) bool {
	if dbservice.Conf().GetBool(constant.ConfigKeyFrontIsListenMouseLongClick) {

		NotifyMouseLongClick(code) //通知给前端
		return true
	}

	return false
}
